package util;

import entity.WordType;

/**
 * Parse the type of word between WordType and String. 
 */
public class Util {
	
	/**
	 * Parse WordType to String. 
	 * @param wt
	 * @return
	 */
	public static WordType parseWordType(String wt){
		WordType result = null;
		
		if(wt == null){
			return null;
		}
		
		if(wt.toUpperCase().equals("NOUN")){
			result = WordType.NOUN;
		}else if(wt.toUpperCase().equals("PRONOUN")){
			result = WordType.PRONOUN;
		}else if(wt.toUpperCase().equals("VERB")){
			result = WordType.VERB;
		}else if(wt.toUpperCase().equals("ADVERB")){
			result = WordType.ADVERB;
		}else if(wt.toUpperCase().equals("ADJECTIVE")){
			result = WordType.ADJECTIVE;
		}else if(wt.toUpperCase().equals("PREPOSITION")){
			result = WordType.PREPOSITION;
		}else if(wt.toUpperCase().equals("ARTICLE")){
			result = WordType.ARTICLE;
		}else if(wt.toUpperCase().equals("PREFIX")){
			result = WordType.PREFIX;
		}else if(wt.toUpperCase().equals("SUFFIX")){
			result = WordType.SUFFIX;
		}else if(wt.toUpperCase().equals("CONJUNCTION")){
			result = WordType.CONJUNCTION;
		}else if(wt.toUpperCase().equals("DETERMINER")){
			result = WordType.DETERMINER;
		}else if(wt.toUpperCase().equals("NUMBER")){
			result = WordType.NUMBER;
		}else if(wt.toUpperCase().equals("* (ANY)") || wt.toUpperCase().equals("*")){
			result = WordType.ANY;
		}
		
		return result;
	}
	
	/**
	 * Parse String to WordType.
	 * @param wt
	 * @return
	 */
	public static String wordTypeString(WordType wt){
		String result = null;
		
		if(wt == null){
			return null;
		}
		
		if(wt == WordType.NOUN){
			result = "Noun";
		}else if(wt == WordType.PRONOUN){
			result = "Pronoun";
		}else if(wt == WordType.VERB){
			result = "Verb";
		}else if(wt == WordType.ADVERB){
			result = "Adverb";
		}else if(wt == WordType.ADJECTIVE){
			result = "Adjective";
		}else if(wt == WordType.PREPOSITION){
			result = "Preposition";
		}else if(wt == WordType.ARTICLE){
			result = "Article";
		}else if(wt == WordType.PREFIX){
			result = "Prefix";
		}else if(wt == WordType.SUFFIX){
			result = "Suffix";
		}else if(wt == WordType.CONJUNCTION){
			result = "Conjunction";
		}else if(wt == WordType.DETERMINER){
			result = "Determiner";
		}else if(wt == WordType.NUMBER){
			result = "Number";
		}else if(wt == WordType.ANY){
			result = "*";
		}
		
		return result;
	}
}
